<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        
    </h:head>
    <h:body>
        <h:form enctype="multipart/form-data">
            <script type="text/javascript">  
                function start() {  
                    statusDialog.show();  
                }  

                function stop() {  
                    statusDialog.hide();  
                }  
            </script>
            <p:panel> 
                <p:messages id="msgs"/> 
                <h:panelGrid >

                    Certificado escaneado:
                    <p:fileUpload fileUploadListener="#{controllerEntradaAtividade.handleFileUpload}" mode="advanced" sizeLimit="300000" allowTypes="/(\.|\/)(pdf)$/"
                                  multiple="false" style="width: 600px;" invalidFileMessage="Apenas PDF" invalidSizeMessage="Tamanho máximo 300kb"
                                  required="true" requiredMessage="É obrigatório anexar o arquivo." showButtons="false" label="Arquivo"/>
                    
                   Atividade Requerida:
                    <!-- POPULANDO COM OBJETO -->
                    <p:selectOneMenu value="#{controllerEntradaAtividade.entradaAtv.id_atividade_complementar}" converter="#{AtividadeComplementarConverter}" style="width: 150px">
                        <f:selectItem itemLabel="-- Selecione --" noSelectionOption="true"/>
                        <f:selectItems value="#{controllerAtvComp.lista}" var="tipo" itemValue="#{tipo}" itemLabel="#{tipo.atividade}"/>
                    </p:selectOneMenu>
                    
                      

                    
                    <p:commandButton value="Solicitar" actionListener="#{controllerEntradaAtividade.salvar()}" ajax="true" update="@form"/>
                    
                    <p:ajaxStatus style="position:fixed;right:20px;top:20px">  
                        <f:facet name="start">
                            <h:graphicImage value="../resources/images/ajax-loader.gif" />
                        </f:facet>
                        <f:facet name="complete">
                            <h:outputText value="" />
                        </f:facet>
                    </p:ajaxStatus>

                </h:panelGrid>
            </p:panel>
            
            <p:dataTable id="tabela" var="p" value="#{controllerEntradaAtividade.listaDM}" emptyMessage="Nada encontrado...">
                <p:column>
                    <h:outputText value="#{p.id_aluno.nome}"/>
                </p:column>
                <p:column>
                    <h:outputText value="#{p.id_atividade_complementar.id_tipo_atividade.tipo_atividade}"/>
                </p:column>
                <p:column>
                    <h:outputText value="#{p.id_atividade_complementar.atividade}"/>
                </p:column>
                <p:column>
                    <h:outputText value="#{p.data_entrada}">
                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                    </h:outputText>
                </p:column>
                <p:column>
                    <p:commandButton value="Download" ajax="false" onclick="PrimeFaces.monitorDownload(start, stop)" icon="ui-icon-arrowthichk-s">  
                        <p:fileDownload value="#{controllerEntradaAtividade.fileDownloadAction()}"/>
                    </p:commandButton>
                </p:column>
                <p:column>
                    <p:commandLink value="apagar" actionListener="#{controllerEntradaAtividade.remover()}" process="@this" ajax="true" update="@form"/>
                </p:column>
            </p:dataTable>
           
            <p:dialog modal="true" widgetVar="statusDialog" draggable="false" closable="false" resizable="false">  
                <p:graphicImage value="../resources/images/ajax-bar.gif" />
            </p:dialog>

        </h:form>
    </h:body>
</html>
